<?php
class Core_Model_DbTable_TallyServices extends Zend_Db_Table_Abstract {
    protected $_name = 'tally_services';
    
    public function getAll($cols = NULL) {
        $select = $this->select();
        if (isset($cols)) {
            $select->from($this->_name, $cols);
        } else {
            $select->from($this->_name);
        }
        $select->where("status = " . STT_ACTIVE);
        return $this->fetchAll($select);
    }
    
    public function getDetail($uid) {
        $cond = $this->getAdapter()->quoteInto("id = (?)", $uid);
        return $this->fetchRow($cond);
    }
    
    public function batchDelete($ids) {
        $cond = $this->getAdapter()->quoteInto("id IN (?)", $ids);
        $this->update(array("status" => STT_DELETE), $cond);
    }
    
    public function getPaginatorAdapter($search_name) {
        $select = $this->select()
                       ->from($this->_name)
                       ->where("service like '%$search_name%'")
                       ->where("status = " . STT_ACTIVE);
        return new Zend_Paginator_Adapter_DbTableSelect($select);
    }
}
?>
